/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo902;

/**
 *
 * @author Administrator
 */
import java.util.*;

public class StringDemo {

    public static void main(String[] args) {
        String name = "zhang";
        String name1 = "zhang" + "san";//"zhangsan"
        System.out.println(name.equals("zhang"));
        // System.out.println(name=="zhang");
        System.out.println(name.length());
        String name2 = name.substring(1, 4);
        System.out.println(name2);
        String name3 = name.substring(4, 5);
        String name4 = name.substring(0, 4);
        String name5 = name.substring(0, name.length() - 1);
        String name6 = name.substring(3);
        String name7 = name.substring(name.length() - 1, name.length());
        String names = "张三李四王五张六";

        int m = 0, n = 0, k = 0;
        String name11;
        for (int i = 0; i < names.length(); i++) {
            name11 = names.substring(i, i + 1);
            // if(names.substring(i,i+1).equals("张"))
            if (name11.equals("张")) {
                m++;
            } else if (name11.equals("李")) {
                n++;
            } else if (name11.equals("王")) {
                k++;
            }

        }
        System.out.println(m);
        System.out.println(n);
        System.out.println(k);

    }
}

